//
//  User.m
//  SDDataTest
//
//  Created by sodao on 12-9-19.
//  Copyright (c) 2012年 sodao. All rights reserved.
//

#import "User.h"

@implementation User
@synthesize hasSyncSina,hasSyncQQ,hasSyncRenRen;
@synthesize hasBoundSina;
@synthesize hasBoundQQ;
@synthesize hasBoundRenRen;
@synthesize isAlterComment;
@synthesize isAlterParse;
@synthesize isAlterFans;
@synthesize isAlterPersonalMsg;
@synthesize canUseMC;
@synthesize canUseSC;
@synthesize lastToken;
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [super encodeWithCoder:aCoder];
    [aCoder encodeBool:self.hasSyncSina forKey:kEncode_syncSina];
    [aCoder encodeBool:self.hasSyncQQ forKey:kEncode_syncQQ];
    [aCoder encodeBool:self.hasSyncRenRen forKey:kEncode_syncRenRen];
    [aCoder encodeBool:self.hasBoundSina forKey:kEncode_boundSina];
    [aCoder encodeBool:self.hasBoundQQ forKey:kEncode_boundQQ];
    [aCoder encodeBool:self.hasBoundRenRen forKey:kEncode_boundRenRen];
    [aCoder encodeBool:self.isAlterComment forKey:kEncode_alterComment];
    [aCoder encodeBool:self.isAlterFans forKey:kEncode_alterFans];
    [aCoder encodeBool:self.isAlterParse forKey:kEncode_alterParse];
    [aCoder encodeBool:self.isAlterPersonalMsg forKey:kEncode_alterPerMsg];
    
    [aCoder encodeInt32:self.canUseMC forKey:kEncode_canUseMC];
    [aCoder encodeInt32:self.canUseSC forKey:kEncode_canUseSC];
    
    [aCoder encodeObject:self.lastToken forKey:kEncode_lastToken];
}
- (id)initWithCoder:(NSCoder *)decoder {
    if (self = [super initWithCoder:decoder]) {
        self.hasSyncSina = [decoder decodeBoolForKey:kEncode_syncSina];
        self.hasSyncQQ = [decoder decodeBoolForKey:kEncode_syncQQ];
        self.hasSyncRenRen = [decoder decodeBoolForKey:kEncode_syncRenRen];
        self.hasBoundSina = [decoder decodeBoolForKey:kEncode_boundSina];
        self.hasBoundQQ = [decoder decodeBoolForKey:kEncode_boundQQ];
        self.hasBoundRenRen = [decoder decodeBoolForKey:kEncode_boundRenRen];
        self.isAlterComment = [decoder decodeBoolForKey:kEncode_alterComment];
        self.isAlterFans = [decoder decodeBoolForKey:kEncode_alterFans];
        self.isAlterParse = [decoder decodeBoolForKey:kEncode_alterParse];
        self.isAlterPersonalMsg = [decoder decodeBoolForKey:kEncode_alterPerMsg];
        self.canUseMC = [decoder decodeBoolForKey:kEncode_canUseMC];
        self.canUseSC = [decoder decodeInt32ForKey:kEncode_canUseSC];
        self.lastToken = [decoder decodeObjectForKey:kEncode_lastToken];
    }
    return self;
}
-(void)updateUserInfoByData:(NSData*)data{
    [self updateInfoByDictionary:[self parserString:[self changeNetDataToString:data]]];
}
-(void)updateUserInfoByDictionary:(NSDictionary *)dictionary{
    [self updateInfoByDictionary:dictionary];
    self.hasBoundQQ=[[dictionary objectForKey:kEncode_boundQQ] boolValue];
    self.hasSyncQQ=[[dictionary objectForKey:kEncode_syncQQ] boolValue];
    self.hasBoundSina=[[dictionary objectForKey:kEncode_boundSina] boolValue];
    self.hasSyncSina=[[dictionary objectForKey:kEncode_syncSina] boolValue];
}
-(void)dealloc{
    [super dealloc];
    [self.lastUpdateDate release];
}
@end
